package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice.model.CourseScript;
import com.sooncode.project.focusservice.service.CourseScriptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("courseScript")
public class CourseScriptController {
    @Autowired
    private CourseScriptService service;

    @PostMapping("courseScript")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }
    @PutMapping("courseScript")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        return service.modify(id,map);
    }
    @DeleteMapping("courseScript")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("courseScripts")
    public Page<CourseScript> getPageList(@RequestParam int pageSize, @RequestParam int pageIndex, @RequestParam Map map){
        map.remove("pageSize");
        map.remove("pageIndex");
        return service.getPageList(pageSize,pageIndex-1,map);
    }
    @GetMapping("publicApi/courseScriptList")
    public List<CourseScript> getCourseScriptList(){
        return service.getCourseScriptList();
    }

}
